/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-11-09 14:52:34
 */
 import Vue from 'vue';
 import VueRouter from 'vue-router';
 // 公共参数菜单
 import commonRoutes from './common';
 import cluesRoutes from './clues';
 import customerRoutes from './customer';
 import financeRoutes from './finance';
 import derivedRoutes from './derived';
 import customerCare from './customerCare';
 import reportRoutes from './report';
 import capitalsettle from './capitalsettle';
 import saleRoutes from './sale';
 import customeService from './customeService';
 import partManage from './partManage';
 import evaluateManage from './evaluateManage';
 import reportManage from './reportManage';
 // TODO cl start
 import notificationManage from './cms-routes/notificationManage';
 import todoTask from './cms-routes/todoTask';
 import notificationManageDLR from './cms-routes/notificationManageDLR';
 import customerManage from './cms-routes/customerManage';
 import origin from './cms-routes/origin';
 import originDLR from './cms-routes/originDLR';
 import projectOperating from './cms-routes/projectOperating';
 // TODO cl end
 //销售客开
 import omYxzs from './omYxzs';
 import dlrYxzs from './dlrYxzs';

 import omSale from './omSale';
 import dealerSale from './dealerSale';

 import omFinance from './omFinance';
 import dealerFinance from './dealerFinance';

 //皮卡
 import omSaleP from './omSaleP';
 import dealerSaleP from './dealerSaleP';

 import omFinanceP from './omFinanceP';
 import dealerFinanceP from './dealerFinanceP';

 // 售后
 import part from './modules/part';
 import repair from './modules/repair';
 import customerRepair from './modules/customerRepair';
 import customerRepairOEM from './modules/customerRepairOEM';

 // 索赔
 import claimDemage from './claimDemage';
 import claimDemageArcfox from './claimDemageArcfox';
 import usedPartsDestructionFactory from './usedPartsDestructionFactory';
 import usedPartsDestructionFactoryDealer from './usedPartsDestructionFactoryDealer';
 // 服务
 import serviceass from './serviceass';
 import assessgrade from './assessgrade';
 import oa from './oa';
 import demands from './demands';
 import technicalManager from './technicalManager';
//客诉
 import customerComplaints from './customerComplaints';
 Vue.use(VueRouter);

 const BasicLayout = () => import('@/layout/BasicLayout');
 const RouteView = () => import('@/layout/RouteView');
 const Login = () => import('@/pages/login/index');
 const getAccessToken = () => import('@/pages/login/getAccessToken');
 const updateWXOpenId = () => import('@/pages/login/updateWXOpenId');
 const wxVersion = () => import('@/pages/common/version/wxVersion');
 const Dashboard = () => import('@/pages/dashboard');
 const TEST = () => import('@/pages/TEST');
 const Redirect = () => import('@/pages/redirect');
 const Nomatch = () => import('@/pages/nomatch');
 const getWeChat = () => import('@/pages/common/auth/userInfo/bindWX/getWeChat');
 // 基础路由
 export const constantRouterMap = [
   {
     path: '/login',
     meta: {
       title: '用户登录'
     },
     component: Login,
     hidden: true
   },
   {
     path: '/getAccessToken',
     meta: {
       title: '微信'
     },
     component: getAccessToken,
     hidden: true
   },
   {
     path: '/updateWXOpenId',
     meta: {
       title: '绑定手机号'
     },
     component: updateWXOpenId,
     hidden: true
   },
   {
     path: '/getWeChat',
     meta: {
       title: '绑定微信号'
     },
     component: getWeChat,
     hidden: true
   },
   {
     path: '/wxVersion',
     meta: {
       title: 'APP下载'
     },
     component: wxVersion,
     hidden: true
   },
   {
     path: '/',
     meta: {
       title: '首页'
     },
     redirect: '/home',
     component: BasicLayout,
     children: [
       {
         path: '/home',
         meta: {
           breadcrumb: false
         },
         component: RouteView,
         children: [
           {
             path: '',
             meta: {
               breadcrumb: false
             },
             component: RouteView,
             children: [
               {
                 path: '',
                 meta: {
                   title: '概览',
                   keepAlive: true
                 },
                 component: Dashboard
               }
             ]
           }
         ]
       },
       {
         path: '/community',
         meta: {
           title: '测试',
           icon: 'el-icon-mobile'
         },
         redirect: '/community/management',
         component: RouteView
       },
       ...commonRoutes,
       ...cluesRoutes,
       ...customerRoutes,
       ...financeRoutes,
       ...derivedRoutes,
       ...reportRoutes,
       ...saleRoutes,
       ...customerCare,
       // TODO cl start
       ...notificationManage,
       ...todoTask,
       ...notificationManageDLR,
       ...origin,
       ...originDLR,
       ...customerManage,
       ...projectOperating,
       // TODO cl end
       // 销售客开
       ...omYxzs,
       ...dlrYxzs,

       ...omSale,
       ...dealerSale,
       ...omFinance,
       ...dealerFinance,

       ...omSaleP,
       ...dealerSaleP,
       ...omFinanceP,
       ...dealerFinanceP,

       // 售后
       ...part,
       ...repair,
       ...customerRepair,
       ...customerRepairOEM,
       ...customeService,
       ...partManage,
       ...evaluateManage,
       ...reportManage,
       ...claimDemage,
       ...claimDemageArcfox,
       ...usedPartsDestructionFactory,
       ...usedPartsDestructionFactoryDealer,
       ...serviceass,
       ...assessgrade,
       ...oa,
       ...demands,
       ...technicalManager,
       ...customerComplaints,
       {
         path: '/redirect',
         component: RouteView,
         children: [
           {
             path: '',
             component: RouteView,
             children: [
               {
                 path: '/redirect/:path*',
                 component: Redirect
               }
             ]
           }
         ]
       }
     ]
   },
   {
     path: '/404',
     hidden: true,
     component: Nomatch
   },
   {
     path: '*',
     redirect: '/404',
     hidden: true
   }
 ];

 export default new VueRouter({
   mode: 'history', // 后端支持可开20191024注释
   routes: constantRouterMap,
   base: window.__MICRO_APP_BASE_ROUTE__ || '/',
   scrollBehavior: () => ({
     y: 0
   })
 });
